/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package pkg_group5;

import javax.jws.WebService;
import javax.jws.WebMethod;
import javax.jws.WebParam;
import java.util.ArrayList;

/**
 *
 * @author Jonny Williams
 */

@WebService()
public class Delivery {

    DeliveryDatabaseFunctions database = new DeliveryDatabaseFunctions();

    int trackingNo = 0;

    @WebMethod
    public String setupDeliveryOrder(
            @WebParam(name = "username") String username,
            @WebParam(name = "password") String password,
            @WebParam(name = "deliveryID") int deliveryID,
            @WebParam(name = "itemID") int itemID,
            @WebParam(name = "address") String address,
            @WebParam(name = "orderMethod") String orderMethod){


        if (database.setupDelivery(username, password) >= 0){

            trackingNo++;

          return "Order set up, tracking number: " + "GB000" + trackingNo;
       }

        return "Could not set order up";
    }


    @WebMethod
    public ArrayList getDeliveryOrder(
            @WebParam(name = "username") String username,
            @WebParam(name = "password") String password,
            @WebParam(name = "deliveryID") int deliveryID,
            @WebParam(name = "itemID") int itemID,
            @WebParam(name = "address") String address,
            @WebParam(name = "orderMethod") String orderMethod){

        ArrayList<DeliveryOrder> orderList = new ArrayList<DeliveryOrder>();
        orderList = database.getDeliveryOrder(deliveryID, itemID, username, address, orderMethod);
        return orderList;
    }


}